Ext.define('PackageManager.store.PackageStore', {
    extend: 'Ext.data.Store',
    model: 'PackageManager.model.Package',

    autoLoad: false,
    autoSync: true,

    proxy: {
        type: 'memory',

        reader: {
            type: 'json'
        }
    },

    listeners: {
        datachanged: function () {

            Ext.getCmp('griddy').getView().refresh();
            Ext.getCmp('griddy').chooseState();

        },
        beforesync: function () {
            var updatedRecords = Ext.data.StoreManager.lookup('ComponentStore').getUpdatedRecords();
            var fullStore = Ext.data.StoreManager.lookup('PackageStoreFull');
            var store = Ext.data.StoreManager.lookup('PackageStore');

            var fullRecord = Ext.create('PackageManager.model.PackageModelFull', {
                id: store.getAt(0).data.id,
                stage: store.getAt(0).data.stage,
                components: [],
                staticDatas: []
            });

            console.log(fullRecord);
            fullRecord.setDirty();
            fullStore.add(fullRecord);
            fullStore.sync();
            this.commitChanges();
        }
    }

});